<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        canvas{border: 1px solid #aaa;}
    </style>
</head>
<body>

<canvas width="600" height="400" class="myCanvas">
    当前的浏览器版本不支持，请升级浏览器
</canvas>
<script>
    var canvas = document.getElementsByClassName('myCanvas')[0];
    var ctx = canvas.getContext('2d');

    ctx.font = "30px 微软雅黑";
    ctx.textAlign = "center";  //以fillText x轴的对其方式
    ctx.fillText('您好！我是微软雅黑文字',100,100);
</script>

</body>
</html>
